package leetcode.d30;

//输入：amount = 5, coins = [1, 2, 5]
//        输出：4
public class Solution {
    public static int change(int amount, int[] coins) {
        int[] d = new int[amount + 1];
        d[0] = 1;
        for (int i = 0; i < coins.length; i++) {
            for (int j = coins[i]; j <= amount; j++) {
                d[j] = d[j] + d[j - coins[i]];
            }
        }
        return d[d.length - 1];
    }

    public static void main(String[] args) {
        int[] coins = {1,2,5};
        int change = change(5,coins);
        System.out.println(change);
    }
}
